#include <libwnck/libwnck.h>

#include "wspace_button.h"
#include "launchers_pad.h"
#include "globals.h"

// 32
// GtkIconSize
#define WSPACE_BUTTON_HEIGHT GTK_ICON_SIZE_SMALL_TOOLBAR


/**
 * wspace_button_new:
 * @id: wspace button number
 *
 * Create one button with appropriate workspace name.
 * Button is a GtkRadioButton widget.
 *
 * Return value: a new GtkWidget.
 **/
GtkWidget * wspace_button_new (guint wspace_id)
{
    GtkWidget *button = NULL;
    WnckWorkspace *workspace;
    const char* workspace_name;


    workspace = wnck_screen_get_workspace (screen, wspace_id);
    workspace_name = wnck_workspace_get_name (workspace);

    button = gtk_radio_button_new_with_label (NULL, workspace_name);
    gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON(button), FALSE);
    gtk_widget_set_size_request (button, -1, WSPACE_BUTTON_HEIGHT);

//    g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_wspace_button_clicked), GUINT_TO_POINTER(wspace_id));

    return button;
}


/**
 * wspace_button_on_clicked:
 * @widget: GtkWidget *
 * @data: gpointer
 *
 * Event. Emited when clicked wokspace button.
 * Change workspace.
 **/
void wspace_button_on_clicked (GtkWidget *widget, gpointer data)
{
    guint           wspace_id;
    WnckWorkspace * wspace;
    guint32         timestamp;


    // workspace id binded with signal
    wspace_id = GPOINTER_TO_UINT(data);

    wspace = wnck_screen_get_workspace (screen, wspace_id);
    timestamp = 0;
    wnck_workspace_activate(wspace, timestamp);
}
